import java.util.Scanner;

public class Main {


    //二维前缀和：
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();
        int q = scan.nextInt();

        long[][] a = new long[n + 1][m + 1];
        long[][] sum = new long[n + 1][m + 1];

        for(int i = 1; i <= n ; i++){
            // i 为列，j 为行
            //处理一维前缀
            for(int j = 1; j <= m ; j++){
                a[i][j] = scan.nextLong();
                sum[i][j] = sum[i][j - 1] + a[i][j];
            }
            //处理二维前缀
            for(int j = 1; j <= m; j++){
                sum[i][j] += sum[i - 1][j];
            }
        }

        //处理 q 次查询
        for(int i = 0; i < q; i++){
            int x1 = scan.nextInt();
            int y1 = scan.nextInt();
            int x2 = scan.nextInt();
            int y2 = scan.nextInt();
            System.out.println(getSum(x1,y1,x2,y2,sum));
        }
    }

    public static long getSum(int x1,int y1,int x2,int y2,long[][] sum){
        //处理越界
        if(x1 > x2 || y1 > y2) return 0;
        //计算区域值的和
        return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];
    }


}
